package com.fingersoft.feature.common;

import android.app.Application;
import android.graphics.Color;
import androidx.annotation.NonNull;

import com.fingersoft.common.preference.UserAppPreferenceHelper;
import com.fingersoft.common.preference.provider.UserIdProvider;
import com.fingersoft.im.utils.AppUtils;
import com.fingersoft.theme.ThemeM;
import com.shougang.call.util.PinyinUtils;

import org.jetbrains.annotations.NotNull;

import cn.fingersoft.util.BuildConfigUtil;

/**
 * Created by liubinbin on 2017/9/9.
 */

public final class SealCheckApiContext extends SealCheckApiContext2 {

    public SealCheckApiContext(Application application) {
        super(application);
    }

    @Override
    public int getColorByName(String colorName) {
        return Color.parseColor(ThemeM.getColorByName(colorName));
    }

    @Override
    public int getThemeColor() {
        return ThemeM.getThemeColor();
    }

    @Override
    public int getTheme() {
        return ThemeM.getTheme();
    }

    @Override
    public String getColorByType(String colorname) {
        return ThemeM.getColorByName(colorname);
    }

    @Override
    public boolean useTheme() {
        return AppUtils.useTheme();
    }

    @Override
    public Boolean isUseWorkcircle() {
        return AppUtils.useWorkcircle();
    }

    @Override
    public Boolean isUseUIVersion2() {
        return BuildConfigUtil.INSTANCE.getString("setUIVersion", "ui1").equals("ui2");
    }

    @Override
    public Boolean isUseThemeWhite() {
        return BuildConfigUtil.INSTANCE.getBoolean("useThemeWhite", false);
    }

    @Override
    public UserAppPreferenceHelper getUserAppPreferenceHelper() {
        return new UserAppPreferenceHelper(new UserIdProvider() {
            @NotNull
            @Override
            public String getUserId() {
                return AppUtils.getUser().getUserId();
            }
        });
    }

    @Override
    public boolean getBuildConfigBoolean(String key, boolean defaultValue) {
        return AppUtils.getBoolean(key,defaultValue);
    }

    @Override
    public String getBuildConfigString(@NonNull String key, @NonNull String defaultValue) {
        return AppUtils.getString(key,defaultValue);
    }

    @Override
    public long getBuildConfigLong(String key, long defaultValue) {
        return AppUtils.getLong(key,defaultValue);
    }

    @Override
    public int getBuildConfigInt(String key, int defaultValue) {
        return AppUtils.getInt(key,defaultValue);
    }

    @Override
    public String getPinYin(String s) {
        return PinyinUtils.getPinYin(s);
    }
    @Override
    public String getFirstSpell(String s) {
        return PinyinUtils.getFirstSpell(s);
    }

    @Override
    public String makeUrl(String api) {
        return AppUtils.makeApiUrl(api);
    }

    @Override
    public String makeAppAgentInfo() {
        return AppUtils.makeAppAgentInfo();
    }

    @Override
    public String getECode() {
        return AppUtils.J_ECODE;
    }

    @Override
    public String getUsername() {
        return AppUtils.getUser().getUserName();
    }

    @Override
    public String getUserId() {
        return AppUtils.getUser().getUserId();
    }

    @Override
    public String getUserToken() {
        return AppUtils.getTokenInfo().getUserToken();
    }

    @Override
    public String getUserCipher() {
        return AppUtils.getUser().getPassword();
    }

    @Override
    public Boolean isUseTheme() {
        return AppUtils.useTheme();
    }

    @Override
    public Boolean isShowH5Menu() {
        return AppUtils.isShowH5Menu();
    }

}
